home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / HACKING / UNIXSEC.TXT < prev    next >
Text File  |  1994-07-17  |  11KB  |  188 lines

  1.  
  2.  
  3.  
  4.                       On the Security of UNIX
  5.  
  6. Recently there has been much interest in the security aspects of operating
  7. systems and software.At issue is the ability to prevent undesired disclosure
  8. of information, destruction of information,and harm to the functioning of the
  9. system.This paper discusses the degree of security which can be provided under
  10. the system and offers a number of hints on how to improve security.The first
  11. fact to face is that UNIX was not developed with security,in any realistic
  12. sense,in mind;this fact alone guarantees a vast number of holes.(Actually the
  13. same statement can be made with respect to most systems.)
  14.  
  15. The area of security in which is theoretically weakest is in protecting
  16. against crashing or at least crippling the operation of the system.The problem
  17. here is not mainly in uncritical acceptance of bad parameters to system calls
  18. (there may be bugs in this area, but none are known)but rather in lack of
  19. checks for excessive consumption of resources.
  20.  
  21. Most notably, there is no limit on the amount of disk storage used, either in
  22. total space allocated or in the number of files or directories.Here is a
  23. particularly ghastly shell sequence guaranteed to stop the system:
  24.  
  25.  
  26. while : ; do
  27.         mkdir x
  28.         cd x
  29. done
  30.  
  31. Either a panic will occur because all the i-nodes on the device are used up,
  32. or all the disk blocks will be consumed, thus preventing anyone from writing
  33. files on the device.In this version of the system,users are prevented from
  34. creating more than a set number of processes simultaneously,so unless users
  35. are in collusion it is unlikely that any one can stop the system altogether.
  36.  
  37. However, creation of 20 or so CPU or disk-bound jobs leaves few resources
  38. available for others.Also, if many large jobs are run simultaneously,swap
  39. space may run out, causing a panic.
  40. It should be evident that excessive consumption of diskspace, files, swap
  41. space and processes can easily occur accidentally in malfunctioning programs
  42. as well as at command level.In fact UNIX is essentially defenseless against
  43. this kind of abuse,nor is there any easy fix.The best that can be said is that
  44. it is generally fairly easy to detect what has happened when disaster strikes
  45. ,to identify the user responsible, and take appropriate action.In practice,we
  46. have found that difficulties in this area are rather rare,but we have not been
  47. faced with malicious users,and enjoy a fairly generous supply of resources
  48. which have served to cushion us against accidental overconsumption.
  49.  
  50. The picture is considerably brighter in the area of protection of information
  51. from unauthorized perusal and destruction.Here the degree of security seems
  52. (almost) adequate theoretically, and the problems lie more in the necessity
  53. for care in the actual use of the system.Each UNIX file has associated with
  54. it eleven bits of protection information together with a user identification
  55. number and a user-group identification number (UID and GID).
  56.  
  57. Nine of the protection bits are used to specify independently permission to
  58. read, to write, and to execute the file to the user himself, to members of the
  59. user's group, and to all other users.Each process generated by or for a user
  60. has associated with it an effective UID and a real UID, and an effective and
  61. real GID.When an attempt is made to access the file for reading, writing, or
  62. executing UID for the process is changed to the UID associated with the file;
  63. the change persists until the process terminates or until the UID changed
  64. again by another execution of a set-UID file.Similarly the effective group ID
  65. of a process is changed to the GID associated with a file when that file is
  66. executed and has the set-GID bit set.The real UID and GID of a process do not
  67. change when any file is executed,but only as the result of a privileged system
  68. call.The basic notion of the set-UID and set-GID bits is that one may write a
  69. program which is executableby others and which maintains files accessible to
  70. others only by that program.
  71.  
  72. The classical example is the game-playing program which maintains records of
  73. the scores of its players.The program itself has to read and write the score
  74. file,but no one but the game's sponsor can be allowed unrestricted access to
  75. the file lest they manipulate the game to their own advantage.
  76.  
  77. The solution is to turn on the set-UID bit of the game program.
  78. When, and only when,it is invoked by players of the game,it may update the
  79. score file but ordinary programs executed by others cannot access the score.
  80. There are a number of special cases involved in determining access permissions.
  81. Since executing a directory as a program is a meaningless operation,the
  82. execute-permission bit, for directories, is taken instead to mean permission
  83. to search the directory for a given file during the scanning of a path name;
  84. thus if a directory has execute permission but no read permission for a given
  85. user, he may access files with known names in the directory,but may not read
  86. (list) the entire contents of the directory.
  87.  
  88. Write permission on a directory is interpreted to mean that the user may
  89. create and delete files in that directory;it is impossible for any user to
  90. write directly into any directory..Another, and from the point of view of
  91. security, much more serious special case is that there is a ``super user''
  92. who is able to read any file and write any non-directory.The super-user is also
  93.  able to change the protection mode and the owner UID and GID of any file and
  94. to invoke privileged system calls.It must be recognized that the mere notion
  95. of a super-user is a theoretical, and usually practical, blemish on any
  96. protection scheme.
  97.  
  98. The first necessity for a secure system is of course arranging that all files
  99. and directories have the proper protection modes.Traditionally, UNIX software
  100. has been exceedingly permissive in this regard;essentially all commands create
  101. files readable and writable by everyone.In the current version,this policy may
  102. be easily adjusted to suit the needs ofthe installation or the individual user.
  103.  
  104. Associated with each process and its descendants is a mask, which is in effect
  105. anded with the mode of every file and directory created by that process.
  106. In this way, users can arrange that, by default,all their files are no more
  107. accessible than they wish.The standard mask, set by login,allows all permiss-
  108. ions to the user himself and to his group,but disallows writing by others.
  109.  
  110. To maintain both data privacy and data integrity,it is necessary, and largely
  111. sufficient,to make one's files inaccessible to others.
  112. The lack of sufficiency could follow from the existence of set-UID programs
  113. created by the user and the possibility of total breach of system security
  114. in one of the ways discussed below(or one of the ways not discussed below).
  115.  
  116. For greater protection,an encryption scheme is available.Since the editor is
  117. able to create encrypted documents, and the crypt command can be used to pipe
  118. such documents into the other text-processing programs,the length of time
  119. during which clear text versions need be available is strictly limited.The
  120. encryption scheme used is not one of the strongest known, but it is judged
  121. adequate, in the sense that cryptanalysisis likely to require considerably 
  122. more effort than more direct methods of reading the encrypted files.For
  123. example, a user who stores data that he regards as truly secret should be
  124. aware that he is implicitly trusting the system administrator not to install a
  125. version of the crypt command that stores every typed password in a file.
  126. Needless to say, the system administrators must be at least as careful as
  127. their most demanding user to place the correct protection mode on the files
  128. under their control.
  129.  
  130. In particular,it is necessary that special files be protected from writing,
  131. and probably reading, by ordinary users when they store sensitive files
  132. belonging to otherusers.It is easy to write programs that examine and change
  133. files by accessing the device on which the files live.
  134.  
  135. On the issue of password security,UNIX is probably better than most systems.
  136. Passwords are stored in an encrypted form which, in the absence of serious
  137. attention from specialists in the field,appears reasona